package com.xu.mode.Strategy;

/**
 * 工厂模式和策略模式整合，这样客户端就可以不需要知道策略模式的具体实现只需要自己输入类型就可以知道不同的算法实现
 */
public class FactoryOrStrategy {
    private Strategy strategy;

    public FactoryOrStrategy(String type) {
        switch (type) {
            case "A":
                strategy = new StrategyA();
                break;
            case "B":
                strategy = new StrategyB();
                break;
            case "C":
                strategy = new StrategyC();
                break;
        }
    }

    public void runThePrice() {
        strategy.getThePrice();
    }
}
